* ANES analysis for: 
* Class, Policy Attitudes and U.S. Presidential Voting in the Post-Industrial Era: The Importance of Issue Salience
* Franko & Witko
* Political Research Quarterly
* Date: 05/25/22


set more off


* Party likes/dislikes.
* 1972-2004 only.
* (Similar to Layman and Carmines 1997)

* D likes.
sum VCF0375a VCF0376a VCF0377a VCF0378a VCF0379a
* D dislikes.
sum VCF0381a VCF0382a VCF0383a VCF0384a VCF0385a
* R likes.
sum VCF0387a VCF0388a VCF0389a VCF0390a VCF0391a
* R dislikes.
sum VCF0393a VCF0394a VCF0395a VCF0396a VCF0397a

* Candidate likes/dislikes.
* D cand. likes.
sum VCF0476a VCF0477a VCF0478a VCF0479a VCF0480a
* D cand. dislikes.
sum VCF0482a VCF0483a VCF0484a VCF0485a VCF0486a
* R cand. likes.
sum VCF0488a VCF0489a VCF0490a VCF0491a VCF0492a
* R cand. dislikes.
sum VCF0494a VCF0495a VCF0496a VCF0497a VCF0498a

* 901/945: Econ
* 946/948: Civil rights/Racial justice/Integration/Desegregation/ Voting Rights
* 949/951: Civil liberties/Freedom of expression/First amendment/ Privacy
* 952/958 1207 1208: Labor policy
* 968/978: Law and order
* 979/984: Public morality
* 985/987: Abortion
* 988/990: Gun control
* 991/993: Busing
* 994/996: Urban problem/Cities
* 1001/1003 1025/1028 : Health care
* 1013/1015: ERA; Women's rights
* 1016/1018: Influx of political/economic/past refugees
* 1019/1021: School prayer
* 1022/1024: Gay rights; Gay marriages
* 1043/1045: Affirmative Action programs 
* 1065/1070: Stem cell research/Biologic research/Cloning research

* 605 606 805 806: spending, size of gov
* 903 904 929/933 938/940 1035/1037: econ policy


* Create vars.
gen part_econ = .
gen cand_econ = .
gen issu_econ = .

gen part_econ1 = .
gen cand_econ1 = .
gen issu_econ1 = .

gen part_cult = .
gen cand_cult = .
gen issu_cult = .

gen part_cult1 = .
gen cand_cult1 = .
gen issu_cult1 = .

gen part_race = .
gen cand_race = .
gen issu_race = .

gen part_race1 = .
gen cand_race1 = .
gen issu_race1 = .

* Make all non-missing obs 0.
foreach v1 of varlist VCF0374 VCF0380 VCF0386 VCF0392 {
	foreach v2 of varlist part_* cand_* issu_* {
		replace `v2' = 0 if inlist(`v1', 1, 5)
		replace `v2' = . if inlist(year, 2008, 2012, 2016)
	}
}

* All party mentions.
local partvars "VCF0375a VCF0376a VCF0377a VCF0378a VCF0379a VCF0381a VCF0382a VCF0383a VCF0384a VCF0385a VCF0387a VCF0388a VCF0389a VCF0390a VCF0391a VCF0393a VCF0394a VCF0395a VCF0396a VCF0397a"

* All candidate mentions.
local candvars "VCF0476a VCF0477a VCF0478a VCF0479a VCF0480a VCF0482a VCF0483a VCF0484a VCF0485a VCF0486a VCF0488a VCF0489a VCF0490a VCF0491a VCF0492a VCF0494a VCF0495a VCF0496a VCF0497a VCF0498a"

* First party mention.
local partvars1 "VCF0375a VCF0381a VCF0387a VCF0393a"

* First candidate mention.
local candvars1 "VCF0476a VCF0482a VCF0488a VCF0494a"


* Econ.
* Party - all mentions.
foreach v of varlist `partvars' {
	replace part_econ = 1 if `v' == 605 | `v' == 606
	replace part_econ = 1 if `v' == 805 | `v' == 806
	replace part_econ = 1 if `v' == 903 | `v' == 904
	replace part_econ = 1 if `v' >= 929 & `v' <= 933
	replace part_econ = 1 if `v' >= 938 & `v' <= 939
	replace part_econ = 1 if `v' >= 1035 & `v' <= 1037
}
* Candidate - all mentions.
foreach v of varlist `candvars' {
	replace cand_econ = 1 if `v' == 605 | `v' == 606
	replace cand_econ = 1 if `v' == 805 | `v' == 806
	replace cand_econ = 1 if `v' == 903 | `v' == 904
	replace cand_econ = 1 if `v' >= 929 & `v' <= 933
	replace cand_econ = 1 if `v' >= 938 & `v' <= 939
	replace cand_econ = 1 if `v' >= 1035 & `v' <= 1037
}
* Combined - all mentions. 
foreach v of varlist `partvars' `candvars' {
	replace issu_econ = 1 if `v' == 605 | `v' == 606
	replace issu_econ = 1 if `v' == 805 | `v' == 806
	replace issu_econ = 1 if `v' == 903 | `v' == 904
	replace issu_econ = 1 if `v' >= 929 & `v' <= 933
	replace issu_econ = 1 if `v' >= 938 & `v' <= 939
	replace issu_econ = 1 if `v' >= 1035 & `v' <= 1037
}

* Econ.
* Party - first mention.
foreach v of varlist `partvars1' {
	replace part_econ1 = 1 if `v' == 605 | `v' == 606
	replace part_econ1 = 1 if `v' == 805 | `v' == 806
	replace part_econ1 = 1 if `v' == 903 | `v' == 904
	replace part_econ1 = 1 if `v' >= 929 & `v' <= 933
	replace part_econ1 = 1 if `v' >= 938 & `v' <= 939
	replace part_econ1 = 1 if `v' >= 1035 & `v' <= 1037
}
* Candidate - first mention.
foreach v of varlist `candvars1' {
	replace cand_econ1 = 1 if `v' == 605 | `v' == 606
	replace cand_econ1 = 1 if `v' == 805 | `v' == 806
	replace cand_econ1 = 1 if `v' == 903 | `v' == 904
	replace cand_econ1 = 1 if `v' >= 929 & `v' <= 933
	replace cand_econ1 = 1 if `v' >= 938 & `v' <= 939
	replace cand_econ1 = 1 if `v' >= 1035 & `v' <= 1037
}
* Combined - first mention. 
foreach v of varlist `partvars1' `candvars1' {
	replace issu_econ1 = 1 if `v' == 605 | `v' == 606
	replace issu_econ1 = 1 if `v' == 805 | `v' == 806
	replace issu_econ1 = 1 if `v' == 903 | `v' == 904
	replace issu_econ1 = 1 if `v' >= 929 & `v' <= 933
	replace issu_econ1 = 1 if `v' >= 938 & `v' <= 939
	replace issu_econ1 = 1 if `v' >= 1035 & `v' <= 1037
}


* Culture.
* 979/984: Public morality
* 985/987: Abortion
* 1022/1024: Gay rights; Gay marriages
* 1239 1240: gay people

* Party - all mentions.
foreach v of varlist `partvars' {
	replace part_cult = 1 if `v' >= 979 & `v' <= 981
	replace part_cult = 1 if `v' >= 985 & `v' <= 987
	replace part_cult = 1 if `v' >= 1022 & `v' <= 1024
	replace part_cult = 1 if `v' == 1239 | `v' == 1240
}
* Candidate - all mentions.
foreach v of varlist `candvars' {
	replace cand_cult = 1 if `v' >= 979 & `v' <= 981
	replace cand_cult = 1 if `v' >= 985 & `v' <= 987
	replace cand_cult = 1 if `v' >= 1022 & `v' <= 1024
	replace cand_cult = 1 if `v' == 1239 | `v' == 1240
}
* Combined - all mentions.
foreach v of varlist `candvars' `partvars' {
	replace issu_cult = 1 if `v' >= 979 & `v' <= 981
	replace issu_cult = 1 if `v' >= 985 & `v' <= 987
	replace issu_cult = 1 if `v' >= 1022 & `v' <= 1024
	replace issu_cult = 1 if `v' == 1239 | `v' == 1240
}

* Culture.
* Party - first mention.
foreach v of varlist `partvars1' {
	replace part_cult1 = 1 if `v' >= 979 & `v' <= 981
	replace part_cult1 = 1 if `v' >= 985 & `v' <= 987
	replace part_cult1 = 1 if `v' >= 1022 & `v' <= 1024
	replace part_cult1 = 1 if `v' == 1239 | `v' == 1240
}
* Candidate - first mention.
foreach v of varlist `candvars1' {
	replace cand_cult1 = 1 if `v' >= 979 & `v' <= 981
	replace cand_cult1 = 1 if `v' >= 985 & `v' <= 987
	replace cand_cult1 = 1 if `v' >= 1022 & `v' <= 1024
	replace cand_cult1 = 1 if `v' == 1239 | `v' == 1240
}
* Combined - first mention.
foreach v of varlist `candvars1' `partvars1' {
	replace issu_cult1 = 1 if `v' >= 979 & `v' <= 981
	replace issu_cult1 = 1 if `v' >= 985 & `v' <= 987
	replace issu_cult1 = 1 if `v' >= 1022 & `v' <= 1024
	replace issu_cult1 = 1 if `v' == 1239 | `v' == 1240
}


* Race.
* 905/907: Welfare/Poverty problems
* 1217/1218: Blacks/Black people/African-Americans
* 1219/1220: People on welfare/ADC 

* Party - all mentions.
foreach v of varlist `partvars' {
	replace part_race = 1 if `v' >= 905 & `v' <= 907
	replace part_race = 1 if `v' >= 1217 & `v' <= 1218
	replace part_race = 1 if `v' == 1219 | `v' == 1220
}
* Candidate - all mentions.
foreach v of varlist `candvars' {
	replace cand_race = 1 if `v' >= 905 & `v' <= 907
	replace cand_race = 1 if `v' >= 1217 & `v' <= 1218
	replace cand_race = 1 if `v' == 1219 | `v' == 1220
}
* Combined - all mentions.
foreach v of varlist `candvars' `partvars' {
	replace issu_race = 1 if `v' >= 905 & `v' <= 907
	replace issu_race = 1 if `v' >= 1217 & `v' <= 1218
	replace issu_race = 1 if `v' == 1219 | `v' == 1220
}

* Race.
* Party - first mention.
foreach v of varlist `partvars1' {
	replace part_race1 = 1 if `v' >= 905 & `v' <= 907
	replace part_race1 = 1 if `v' >= 1217 & `v' <= 1218
	replace part_race1 = 1 if `v' == 1219 | `v' == 1220
}
* Candidate - first mention.
foreach v of varlist `candvars1' {
	replace cand_race1 = 1 if `v' >= 905 & `v' <= 907
	replace cand_race1 = 1 if `v' >= 1217 & `v' <= 1218
	replace cand_race1 = 1 if `v' == 1219 | `v' == 1220
}
* Combined - first mention.
foreach v of varlist `candvars1' `partvars1' {
	replace issu_race1 = 1 if `v' >= 905 & `v' <= 907
	replace issu_race1 = 1 if `v' >= 1217 & `v' <= 1218
	replace issu_race1 = 1 if `v' == 1219 | `v' == 1220
}


* Variables by year.
tabstat demvote jobs01 culpol01 racepol01 issu_econ1 issu_cult1 issu_race1, by(year) stat(n)


* Policy and salience.
melogit demvote jobs01 culpol01 racepol01 pid7 polviews white age female south i.issu_econ1 i.issu_cult1 i.issu_race1 c.jobs01#issu_econ1 c.culpol01#issu_cult1 c.racepol01#issu_race1 || year: 

estimates store dvp_anes_sal


melogit demvote jobs01 culpol01 racepol01 pid7 polviews age female south i.issu_econ1 i.issu_cult1 i.issu_race1 c.jobs01#issu_econ1 c.culpol01#issu_cult1 c.racepol01#issu_race1 if white==1 || year: 

estimates store dvp_anes_sal_wo


* Effects.
estimates restore dvp_anes_sal

margins , dydx(jobs01) at(issu_econ1=(0 1)) saving(results/vote_salient_jobs.dta, replace)
margins , dydx(culpol01) at(issu_cult1=(0 1)) saving(results/vote_salient_cult.dta, replace)

* Calculate difference uncertainty.
estimates restore dvp_anes_sal
margins , dydx(jobs01) at(issu_econ1=(0 1)) post
lincom _b[2._at] - _b[1._at]

estimates restore dvp_anes_sal
margins , dydx(culpol01) at(issu_cult1=(0 1)) post
lincom _b[2._at] - _b[1._at]


